import 'package:flutter/material.dart';
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
import 'package:get/get.dart';
import 'package:mesh/page/main/main_screen.dart';
import '../../function/states/state_initializer.dart';

/// 启动页面
class AppLaunchScreen extends StatefulWidget {
  const AppLaunchScreen({super.key});

  @override
  State<AppLaunchScreen> createState() => _AppLaunchScreenState();
}

class _AppLaunchScreenState extends State<AppLaunchScreen> {
  @override
  void initState() {
    super.initState();
    // 初始化所有状态
    StateInitializer.initializeAllStates();

    // 延迟跳转效果
    Future.delayed(Duration(seconds: 3), () {
      Get.offAll(() => const MainScreen());
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        width: double.infinity,
        height: double.infinity,
        decoration: BoxDecoration(
          image: DecorationImage(
            image: AssetImage('assets/images/common_bg.png'),
            fit: BoxFit.cover,
          ),
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            SizedBox(height: 200.h),
            ClipRRect(
              borderRadius: BorderRadius.circular(12.r),
              child: Image.asset(
                'assets/images/logo.png',
                width: 118.w,
                height: 118.w,
                fit: BoxFit.cover,
              ).boxShadow(
                blurRadius: 10.r,
                offset: Offset(0, 4.h),
                color: Colors.black.withOpacity(0.1),
              ),
            ),
            SizedBox(height: 40.h),
            CircularProgressIndicator(
              valueColor: AlwaysStoppedAnimation<Color>(Color(0xFFFF8A3C)),
              strokeWidth: 3.w,
            ).opacity(0.8).scale(all: 1.2),
          ],
        ),
      ),
    );
  }
}
